Skip to content

Conversation

@ajworkos
Copy link
Contributor

@ajworkos ajworkos commented Feb 1, 2026

Summary

Adds custom_attributes field to OrganizationMembership model to expose custom attributes from identity providers.

Changes

  • Added custom_attributes field to OrganizationMembership type/model
  • Field type: Record/Map/Dictionary of string keys to any values
  • Always present, defaults to empty object {}
  • Updated fixtures and tests

API Field Details

The field will be present in:

  • REST API responses
  • Webhook events
  • Events API responses

JSON field name: custom_attributes (snake_case)

- Add idp_attributes: dict[str, Any] to OrganizationMembership model
- Update MockOrganizationMembership fixture
- All organization_membership tests pass

This change adds support for IDP custom attributes on organization
memberships, which are sourced from the identity provider and stored
as customAttributes in the API.

Related to workos/workos PR #50470

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ajworkos ajworkos requested a review from a team as a code owner February 1, 2026 16:17
@ajworkos ajworkos requested a review from mattgd February 1, 2026 16:17
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

This PR adds the idp_attributes field to OrganizationMembership to expose IDP custom attributes from the WorkOS API (which provides them as customAttributes).

Key Changes:

  • Added idp_attributes: dict[str, Any] field to OrganizationMembership model
  • Updated MockOrganizationMembership fixture with idp_attributes={}

Issues Found:

  • Python 3.8 compatibility broken: The PR uses lowercase dict[str, Any] syntax which is only available in Python 3.9+, but the project supports Python >=3.8. The codebase consistently uses Dict[str, Any] from the typing module for compatibility.
  • Missing import: The Dict type needs to be imported from typing module.
  • Verify field optionality: Confirm whether the API always returns this field. If it can be missing for older records or when IDP attributes aren't configured, it should be Optional[Dict[str, Any]] = None to prevent deserialization errors.

Confidence Score: 2/5

  • This PR will break Python 3.8 compatibility and should not be merged without fixes
  • Score reflects critical Python 3.8 compatibility issue with lowercase dict syntax. The codebase requires Python >=3.8 support but uses Python 3.9+ syntax. This will cause runtime errors on Python 3.8 installations.
  • Pay close attention to src/workos/types/user_management/organization_membership.py which requires type annotation fixes

Important Files Changed

Filename Overview
src/workos/types/user_management/organization_membership.py Added idp_attributes field but used Python 3.9+ syntax incompatible with Python 3.8; needs Dict import and capitalization
tests/utils/fixtures/mock_organization_membership.py Correctly added idp_attributes={} to mock fixture; clean implementation

Sequence Diagram

sequenceDiagram
    participant IDP as Identity Provider
    participant API as WorkOS API
    participant SDK as Python SDK
    participant App as Application Code
    
    IDP->>API: Provides user attributes<br/>(department, employee_id, etc.)
    Note over API: Stores as customAttributes<br/>in organizationMembership
    
    App->>SDK: list_organization_memberships()
    SDK->>API: GET /organization_memberships
    API->>SDK: Returns JSON with customAttributes
    Note over SDK: Deserializes to<br/>OrganizationMembership.idp_attributes
    SDK->>App: OrganizationMembership object
    
    Note over App: Access IDP attributes:<br/>membership.idp_attributes["department"]
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

ajworkos and others added 2 commits February 1, 2026 12:28
Use Dict[str, Any] instead of dict[str, Any] for Python 3.8 compatibility.
The lowercase dict syntax is only available in Python 3.9+.

Fixes issue identified by Greptile bot review.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ajworkos ajworkos changed the title Add idp_attributes field to OrganizationMembership Add custom_attributes field to OrganizationMembership Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants